import React, { useEffect, useState } from "react";
//components
import UserInfo from "../../components/userinfo";
import UseAPI from "../../components/useapi";
// import Map from "../../components/map";


import {
  handleJSAPIAccess,
  handleUserAuth,
  getRoleList,
} from "../../utils/auth_access_util";
import "./index.css";

export default function Home() {
  const [userInfo, setUserInfo] = useState({});
  useEffect(() => {
    //鉴权处理
    handleJSAPIAccess((isSucces) => {
      console.log("handleJSAPIAccess OK: ", isSucces);
      //免登处理
      handleUserAuth(async (userInfo) => {
        console.log("userInfo", userInfo);
        setUserInfo(userInfo);
        // getRoleList(userInfo.access_token);
      });
    });

  }, []); // eslint-disable-line react-hooks/exhaustive-deps

  return (
    <div className="home">
      {/* <UserInfo userInfo={userInfo} /> */}
      <UseAPI />
    </div>
  );
}
